package cn.zcy.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class MyProxyStudent {
    static Student student =new Student();

    public static Proson getStudent() {
        Proson students = (Proson) Proxy.newProxyInstance(student.getClass().getClassLoader(), student.getClass().getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Object resd = null;
                if(method.getName().equalsIgnoreCase("study")){
                    System.out.println("好好学习天天向上");
                    return null;
                }else {

                    resd=method.invoke(student, args);
                    return resd;
                }

            }
        });
        return students;
    }
}
